<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title th:text="${question.title}"></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <link rel="stylesheet" href="/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/community.css">
    <link rel="stylesheet" href="/css/editormd.preview.min.css">

    <script src="/js/jquery.js"></script>
    <script src="/js/jquery-core.js"></script>
    <script src="/js/jquery-3.4.1.min.js" type="application/javascript"></script>
    <script src="/js/bootstrap.min.js" type="application/javascript"></script>
    <script src="/js/community.js" type="application/javascript"></script>
    <script src="/js/editormd.min.js" type="application/javascript"></script>
    <script src="/js/lib/marked.min.js" type="application/javascript"></script>
    <script src="/js/lib/prettify.min.js" type="application/javascript"></script>
    <link rel="icon" type="image/x-icon" href="/img/favicon.ico">

</head>
<body>
<!--引入导航栏-->
<div th:insert="common/navigation :: nav"></div>

<div class="container-fluid main profile">
    <div class="row">
        <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h3><span th:text="${question.title}" class="bold"></span></h3>
                <span class="text-desc">
                作者：<span th:text="${question.user.name}"></span> |
                发布时间：<span th:text="${#dates.format(question.gmtCreate,'yyyy-MM-dd  HH:mm')}"></span> |
                阅读数：<span th:text="${question.viewCount}"></span>&nbsp;&nbsp;&nbsp;&nbsp;
                     <a th:href="@{'/publish/'+${question.id}}" class="community-menu"
                        th:if="${session.user != null && session.user.id ==question.creator}">
                    <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                    编辑
                </a>&nbsp;&nbsp;
                <a th:href="@{'/delete/'+${question.id}}" class="community-menu"
                   th:if="${session.user != null && session.user.id ==question.creator}"
                   onclick="return deleteQuestion()">
                    <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
                    删除
                </a>
                </span>
                <hr>
                <span class="label label-info" style="margin-right:4px" th:each="tag : ${question.tag.split(',')}">
                    <span class="glyphicon glyphicon-tags"></span>
                    <span class="label label-info" th:text="${tag}"></span>
                </span>
                <hr>
                <h4 class="bold">问题内容：</h4><br>
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 content" id="question-view">
                    <textarea style="display: none" th:text="${question.description}"></textarea>
                </div>
                <script type="text/javascript">
                    $(function () {
                        editormd.markdownToHTML("question-view",{});
                    });
                </script>

                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            </div>

            <!--            回复内容-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4>
                    <span th:text="${question.commentCount}"></span> 个回复
                </h4>
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment-sp">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comments" th:each="comment : ${comments}">
                    <div class="media">
                        <div class="media-left">
                            <a href="#">
                                <img class="media-object img-rounded" th:src="${comment.user.avatarUrl}">
                            </a>
                        </div>
                        <div class="media-body" th:id="${'comment-'+comment.id}">
                            <h5 class="media-heading">
                                <span th:text="${comment.user.name}"></span>
                            </h5>
                            <div th:text="${comment.content}"></div>
                            <div class="menu">
                                <span class="glyphicon glyphicon-thumbs-up icon" th:data-id="${comment.id}"
                                      th:id="${'ThumbsUp-'+comment.id}" onclick="thumbsUp(this)">
                                    <span th:text="${comment.getLikeCount()}" class="count"
                                          th:id="${'LikeCount-'+comment.id}"></span>
                                </span>
                                <span class="glyphicon glyphicon-comment icon" th:data-id="${comment.id}"
                                      th:id="${'collapse-'+comment.id}" onclick="collapseComments(this)">
                                    <span th:text="${comment.getCommentCount()}" class="count"
                                          th:id="${'CommentCount-'+comment.id}"></span>
                                </span>
                                <span class="pull-right"
                                      th:text="${#dates.format(comment.gmtCreate,'yyyy-MM-dd HH:mm')}"></span>
                            </div>
                            <!--二级评论-->
                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 collapse sub-comments"
                                 th:id="${'comment2-'+comment.id}">

                                <!--                                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comments" th:each="comment : ${comments}">-->
                                <!--                                    <div class="media">-->
                                <!--                                        <div class="media-left">-->
                                <!--                                            <img class="media-object img-rounded" th:src="${comment.user.avatarUrl}">-->
                                <!--                                        </div>-->
                                <!--                                        <div class="media-body">-->
                                <!--                                            <h5 class="media-heading">-->
                                <!--                                                <span th:text="${comment.user.name}"></span>-->
                                <!--                                            </h5>-->
                                <!--                                            <div th:text="${comment.content}"></div>-->
                                <!--                                            <div class="menu">-->
                                <!--                                                <span class="pull-right" th:text="${#dates.format(comment.gmtCreate,'yyyy-MM-dd')}"></span>-->
                                <!--                                            </div>-->
                                <!--                                        </div>-->
                                <!--                                    </div>-->
                                <!--                                </div>-->

                                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                    <input type="text" class="form-control" placeholder="回复..."
                                           th:id="${'input-'+comment.id}">
                                    <button type="button" class="btn btn-success pull-right" onclick="comment(this)"
                                            th:data-id="${comment.id}">回复
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--            回复输入框-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4>回复</h4>
                <hr class="line">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="comment_section"
                     th:if="${session.user != null}">
                    <div class="media">
                        <div class="media-left">
                            <a href="#">
                                <img class="media-object img-rounded" th:src="${session.user.avatarUrl}">
                            </a>
                        </div>
                        <div class="media-body">
                            <h5 class="media-heading">
                                <span th:text="${session.user.name}"></span>
                            </h5>
                        </div>
                    </div>
                    <input type="hidden" id="question_id" th:value="${question.id}">
                    <textarea class="form-control comment" rows="6" id="comment_content"></textarea>
                    <button type="button" class="btn btn-success btn-comment" onclick="post()">回复</button>

                </div>
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" th:if="${session.user == null}">
                    <button type="button" class="btn btn-success btn-comment" onclick="login()">点击登陆后可进行回复</button>
<!--                    <a href="https://github.com/login/oauth/authorize?client_id=7eb8077db329c933c502&redirect_uri=http://www.ldbin.club/callback&scope=user&state=1" class="btn btn-success btn-comment">点击登陆后可进行回复</a>-->
                </div>
            </div>
        </div>

        <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12 ">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4 class="bold">发起人</h4>
                <div class="media">
                    <div class="media-left">
                        <a href="#">
                            <img class="media-object img-rounded" th:src="${question.user.avatarUrl}">
                        </a>
                    </div>
                    <div class="media-body">
                        <h5 class="media-heading">
                            <span th:text="${question.user.name}"></span>
                        </h5>
                        <span class="text-desc">
                            个人说明：<span th:text="${question.user.bio}"></span>
                        </span>
                    </div>
                </div>
            </div>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4 class="bold">扫码加站长微信哦</h4>
                <img src="/img/wexin.png" class="question-wechat">
            </div>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4 class="bold">相关问题</h4>
                <ul class="question-related">
                    <li th:each="related : ${relateQuestions}">
                        <a th:href="@{'/question/'+${related.id}}" th:text="${related.title}"></a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
<div th:insert="common/footer :: foot"></div>

</body>
</html>